package com.jhte.scheduleJob.controller;

import com.jhte.scheduleJob.base.util.BaseResponse;
import com.jhte.scheduleJob.service.QuartzLogService;
import com.jhte.scheduleJob.vo.QueQuartzLogRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description
 * @author wuchun
 * @create 2018/2/7 10:07
 */
@RestController
@RequestMapping(value = "/scheduleJob")
public class QuartzLogController {

    @Autowired
    private QuartzLogService quartzLogService;

    private static Logger logger = LoggerFactory.getLogger(QuartzLogController.class);

    /**
     * 查询定时任务日志列表
     *
     * @param queQuartzLogRequest
     * @return
     */
    @RequestMapping(value = "/queryQuartzLogList", method = {RequestMethod.GET,
            RequestMethod.POST}, consumes = "application/json", produces = "application/json;charset=UTF-8")
    public BaseResponse queryQuartzLogList(@RequestBody QueQuartzLogRequest queQuartzLogRequest) {
        logger.info("enter api /Hisportal/scheduleJob/queryQuartzLogList");
        BaseResponse baseResponse = new BaseResponse();
        try {
            Map<String, Object> map = quartzLogService.queryQuartzLogList(queQuartzLogRequest);
            baseResponse.success(map);
        } catch (Exception e) {
            baseResponse.exception();
            logger.error("/Hisportal/scheduleJob/queryQuartzLogList failed!", e);
        }
        return baseResponse;
    }

}
